import "./index.scss";
import $ from "jquery";
import ProfileMgr from "../../data/ProfileMgr.js";
import LazyLoad from "../../modules/lazyLoad/lazyload.js";
import CreateWineType from "../../parts/inc/createWineType.js";
import IndexBanner from "../../parts/banner/index_banner.js";
import ListRender from "../../parts/listRender/index_listRender.js";
import IndexPagination from "../../parts/listRender/index_pagination.js";
import Cart from "../../parts/cart/cart";
import Header from "../../parts/inc/header.js";

$(function(){
    $('.web_head').load('./header.html',function(){
        // 读取本地数据
        ProfileMgr.load();
        new Header();
        
        // 主页二级菜单
        new CreateWineType(".list_xuanwine ul");
        // banner
        new IndexBanner({
            pre: ".hb_top .pre",
            next: ".hb_top .next",
            ul: ".hb_top ul",
            inds: ".hb_top .btn"
        });
        /******************购物车**********************/ 
        let myCart = new Cart();
        /******************购物车**********************/ 
        // 懒加载
        let lazyLoad = new LazyLoad();
        // 列表渲染
        let listRender = new ListRender();
        listRender.init(".forth_hot ul", myCart.addCart.bind(myCart));
        // 分页
        new IndexPagination(36,function(data){
            listRender.setListData(data);
            lazyLoad.addListData(".cont_wineli .pic_tu .photos img");
        });
    }); 
    $('.footer').load('./footer.html');
 });
